public class Main {
    public static void main(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addFirst(5);
        mySingleList.addFirst(4);
        mySingleList.addFirst(8);
        mySingleList.addFirst(1);
        mySingleList.addFirst(4);
        MySingleList.ListNode ret = mySingleList.cycleList(mySingleList.head);
        mySingleList.display(ret);
    }
    public static void main7(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addFirst(5);
        mySingleList.addFirst(4);
        mySingleList.addFirst(8);
        mySingleList.addFirst(1);
        mySingleList.addFirst(4);
        mySingleList.cycleList(mySingleList.head);
        MySingleList.ListNode ret9 = mySingleList.detectCycle(mySingleList.head);
        mySingleList.display(ret9);
    }
    public static void main6(String[] args) {
       MySingleList mySingleList = new MySingleList();
//        mySingleList.addFirst(5);
//        mySingleList.addFirst(4);
//        mySingleList.addFirst(8);
//        mySingleList.addFirst(1);
//        mySingleList.addFirst(4);

//        mySingleList2.addFirst(5);
//        mySingleList2.addFirst(4);
//        mySingleList2.addFirst(8);
//        mySingleList2.addFirst(1);
//        mySingleList2.addFirst(6);
//        mySingleList2.addFirst(5);
        //mySingleList.display();

        MySingleList.ListNode ret9 = mySingleList.createYList();
        mySingleList.display(ret9);
        System.out.println("======");
      // MySingleList.ListNode ret7 = mySingleList.getIntersectionNode(mySingleList.head,mySingleList2.head);
      // mySingleList.display(ret7);
    }
    public static void main5(String[] args) {
        MySingleList mySingleList = new MySingleList();

        mySingleList.addFirst(23);
        mySingleList.addFirst(5);
        //mySingleList.addFirst(12);
        mySingleList.addFirst(45);
        mySingleList.addFirst(23);

//        mySingleList.display();//23 45 12 45 23
//        mySingleList.Partition(30);

        mySingleList.display();

        System.out.println(mySingleList.palindromeList());
    }
    public static void main4(String[] args) {
        MySingleList mySingleList = new MySingleList();

        mySingleList.addFirst(88);
        mySingleList.addFirst(78);
        mySingleList.addFirst(56);
        mySingleList.addFirst(45);
        mySingleList.addFirst(23);
        mySingleList.addFirst(12);
        MySingleList mySingleList1 = new MySingleList();
        mySingleList1.addLast(2);
        mySingleList1.addLast(18);
        mySingleList1.addLast(33);
        mySingleList1.addLast(90);
        mySingleList.display();
        mySingleList1.display();

        MySingleList.ListNode ret5 = MySingleList.mergeTwoLists(mySingleList.head, mySingleList1.head);
        mySingleList1.display(ret5);
    }
    public static void main3(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addFirst(88);
        mySingleList.addFirst(78);
        mySingleList.addFirst(56);
        mySingleList.addFirst(45);
        mySingleList.addFirst(23);
        mySingleList.addFirst(12);
        mySingleList.display();
        MySingleList.ListNode ret2 = mySingleList.findIndexLastVal(2);
        System.out.println(ret2.val);

        MySingleList.ListNode ret3 = mySingleList.findIndexLastVal1(3);
        System.out.println(ret3.val);
    }
    public static void main2(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addFirst(88);
        mySingleList.addFirst(78);
        mySingleList.addFirst(56);
        mySingleList.addFirst(45);
        mySingleList.addFirst(23);
        mySingleList.addFirst(12);//12 23 45 56
        mySingleList.display();

        MySingleList.ListNode ret =  mySingleList.middleNode();
       // System.out.println(ret.val);
        //System.out.println(mySingleList.middleNode1());
        MySingleList.ListNode ret1 = mySingleList.middleNode1();
        System.out.println("ret1="+ret1.val);
       // System.out.println(mySingleList.middleNode1());
    }
    public static void main1(String[] args) {
        MySingleList mySingleList = new MySingleList();
        //mySingleList.createList();


        System.out.println(mySingleList.contains(99));
        mySingleList.addFirst(56);
        mySingleList.addFirst(45);
        mySingleList.addFirst(23);
        mySingleList.addFirst(12);

//        mySingleList.addLast(12);
//        mySingleList.addLast(23);
//        mySingleList.addLast(34);
//        mySingleList.addLast(45);
        //mySingleList.addIndex(3,8);
       // mySingleList.removeAllKey(12);
       // mySingleList.clear();
        mySingleList.display();//12 23 45 56
        mySingleList.ReverseTheList();
        mySingleList.display();//12 23 45 56
        MySingleList.ListNode ret =mySingleList.ReverseTheList();
        mySingleList.display(ret.next);//23 45 56
        System.out.println(mySingleList.size());
    }
}

